home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-src / doc / vbccppc.doc < prev    next >
Text File  |  1999-01-01  |  8KB  |  220 lines

  1. vbcc - C compiler (c) in 1995-99 by Volker Barthelmann
  2.  
  3.  
  4. INTRODUCTION
  5.  
  6.     vbcc is a free portable and retargetable ANSI C compiler.
  7.     It is clearly split into a target independant and a target dependant
  8.     part and supports emulating datatypes of the target machine on any
  9.     other machine so that it is possible to e.g. make a crosscompiler for
  10.     a 64bit machine on a 32bit machine.
  11.     This document only deals with the target dependant parts of the
  12.     PowerPC version.
  13.  
  14.  
  15. LEGAL
  16.  
  17.     vbcc is (c) in 1995-99 by Volker Barthelmann. All code is written by me
  18.     and may be freely redistributed as long as no modifications are made
  19.     and nothing is charged for it.
  20.     Non-commercial usage of vbcc is allowed without any restrictions.
  21.     Commercial usage needs my written consent.
  22.  
  23.     Sending me money, gifts, postcards etc. would of course be very nice
  24.     and may encourage further development of vbcc, but is not legally or
  25.     morally necessary to use vbcc.
  26.  
  27.  
  28. ADDITIONAL OPTIONS FOR THIS VERSION
  29.  
  30.     -merge-constants
  31.  
  32.                 Place identical floating point constants at the same
  33.                 memory location. This can reduce program size and increase
  34.                 compilation time.
  35.  
  36.     -const-in-data
  37.  
  38.                 By default constant data will be placed in the .rodata
  39.                 section. Using this option it will be placed in the data
  40.                 section.
  41.                 Note that on operating systems with memory protection this
  42.                 option will disable write-protection of constant data.
  43.  
  44.     -fsub-zero
  45.  
  46.                 Use fsub to load a floating-point-register with zero.
  47.                 This is faster but requires all registers to always contain
  48.                 valid values (i.e. no NaNs etc.) which may not be the case
  49.                 depending on startup-code, libraries etc.
  50.  
  51.     -amiga-align
  52.  
  53.                 Do not require any alignments greater than 2 bytes.
  54.                 This is needed when accessing Amiga system-structures, but
  55.                 can cause a performance penalty.
  56.  
  57.     -elf
  58.  
  59.                 Do not prefix symbols with '_'. Prefix labels with '.'.
  60.  
  61.     -poweropen
  62.  
  63.                 Generate code for the PowerOpen ABI like used in AIX.
  64.                 This does not work correctly yet.
  65.  
  66.     -sc
  67.  
  68.                 Generate code for the modified PowerOpen ABI used in the
  69.                 StormC compiler.
  70.  
  71.     -no-regnames
  72.  
  73.                 Do not use register names but only numbers. This is necessary
  74.                 to avoid name-conflicts when using -elf.
  75.  
  76.     -setccs
  77.  
  78.                 The V.4 ABI requires that when varargs-functions are called
  79.                 with arguments passed in the floating-point registers this
  80.                 has to be signalled in a certain bit of the condition code
  81.                 register. vbcc usually doesn't make use of this and
  82.                 therefore does not care about that bit by default.
  83.                 This may lead to problems if you link objects compiled by
  84.                 vbcc to objects not compiled by vbcc (e.g. a different
  85.                 C-library) and call varargs-functions with floating-point
  86.                 arguments.
  87.                 In this case -setccs might help.
  88.  
  89.     -peephole
  90.  
  91.                 Perform several peephole optimizations. Currently includes:
  92.                  - better use of d16(r) addressing
  93.                  - use of indexed addressing modes
  94.                  - use of update-flag
  95.                  - use of record-flag
  96.                  - use of condition-code-registers to avoid certain branches
  97.  
  98.     -use-lmw
  99.  
  100.                 Use lmw/stmw-instructions. This can significantly reduce
  101.                 code-size. However these instructions may be slower on
  102.                 certain PPCs.
  103.  
  104.  
  105. SOME INTERNALS
  106.  
  107.     The current version generates assembly output for use with the "pasm"
  108.     assembler by Frank Wille. The generated code should work on 32bit systems
  109.     based on a PowerPC CPU using the V.4 ABI.
  110.  
  111.     The register names are:
  112.  
  113.         r0 through r31 for the general purpose registers,
  114.         f0 through f31 for the floating point registers and
  115.         cr0 through cr7 for the condition-code registers.
  116.  
  117.     The registers r0, r3-r12, f0-f13 and cr0-cr1 are used as scratch registers
  118.     (i.e. they can be destroyed in function calls), all other registers are
  119.     preserved. r1 is the stack-pointer and r13 is the small-data-pointer if
  120.     small-data-mode is used.
  121.  
  122.     The first 8 function arguments which have integer or pointer types
  123.     are passed in registers r3 through r10 and the first 8 floating-point
  124.     arguments are passed in registers f1 through f8. All other arguments
  125.     are passed on the stack.
  126.  
  127.     Integers and pointers are returned in r3, floats and doubles in f1.
  128.     All other types are returned by passing the function the address
  129.     of the result as a hidden argument - so when you call such a function
  130.     without a proper declaration in scope you can expect a crash.
  131.  
  132.     The elementary data types are represented like:
  133.  
  134.     type        size in bits        alignment in bytes (-amiga-align)
  135.  
  136.     char                8                       1 (1)
  137.     short              16                       2 (2)
  138.     int                32                       4 (2)
  139.     long               32                       4 (2)
  140.     all pointers       32                       4 (2)
  141.     float              32                       4 (2)
  142.     double             64                       8 (2)
  143.  
  144.  
  145. TARGET-SPECIFIC VARIABLE ATTRIBUTES
  146.  
  147.     The m68k-backend offers the following variable attributes:
  148.  
  149.     __saveds:   Load the pointer to the small data segment at
  150.                 function-entry. Applicable only to functions.
  151.  
  152.     __chip:     Place variable in chip-memory. Only applicable on
  153.                 AmigaOS to variables with static storage-duration.
  154.  
  155.     __far:      Do not place this variable in the small-data segment
  156.                 in small-data-mode. No effect in large-data-mode.
  157.                 Only applicable to variables with static storage-
  158.                 duration.
  159.  
  160.     __near:     Currently ignored.
  161.  
  162.  
  163. STDARG
  164.  
  165.     A possible <stdarg.h> for V.4 ABI could look like this:
  166.  
  167.     typedef struct {
  168.       int gpr;
  169.       int fpr;
  170.       char *regbase;
  171.       char *membase;
  172.     } va_list;
  173.  
  174.     char *__va_start(void);
  175.     char *__va_regbase(void);
  176.     int __va_fixedgpr(void);
  177.     int __va_fixedfpr(void);
  178.  
  179.     #define va_start(vl,dummy) \
  180.       ( \
  181.         vl.gpr=__va_fixedgpr(), \
  182.         vl.fpr=__va_fixedfpr(), \
  183.         vl.regbase=__va_regbase(), \
  184.         vl.membase=__va_start() \
  185.       )
  186.  
  187.     #define va_end(vl) (vl.regbase=vl.membase=0)
  188.  
  189.     #define __va_size(type) ((sizeof(type)+3)/4*4)
  190.     #define va_arg(vl,type) \
  191.       (__typeof(type)&15)>8? \
  192.         (vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
  193.       : \
  194.        ( \
  195.         (((__typeof(type)&15)==5||(__typeof(type)&15)==6)) ? \
  196.          ( \
  197.           ++vl.fpr<=8 ? \
  198.              ((double*)(vl.regbase+32))[vl.fpr] \
  199.           : \
  200.             (vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
  201.          ) \
  202.         : \
  203.          ( \
  204.           ++vl.gpr<=8 ? \
  205.             ((int*)(vl.regbase+0))[vl.gpr] \
  206.           : \
  207.             (vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
  208.          ) \
  209.        ) \
  210.  
  211.  
  212. KNOWN PROBLEMS
  213.  
  214.     - composite types are put on the stack rather than passed via pointer
  215.     - indication of fp-register-args with bit 6 of cr is not done well
  216.  
  217.  
  218. Volker Barthelmann                                      volker@vb.franken.de
  219.  
  220.